﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
namespace Andrewl.XnaHelpers.Input
{
    public class Input_Keyboard
    {
        #region Variable Declarations

        public KeyboardState previousKeyboardState;

        public KeyboardState currentKeyboardState;

        #endregion

        public Input_Keyboard()
        { }

        public void Update()
        {
            previousKeyboardState = currentKeyboardState;
            currentKeyboardState = Keyboard.GetState();
        }

        #region Functions

        public bool IsKeyPressed(Keys key)
        {
            if (currentKeyboardState.IsKeyDown(key) && !previousKeyboardState.IsKeyDown(key))
                return true;
            else
                return false;
        }

        public bool IsKeyDown(Keys key)
        {
            if (currentKeyboardState.IsKeyDown(key))
                return true;
            else
                return false;
        }

        public bool IsKeyUp(Keys key)
        {
            if (currentKeyboardState.IsKeyUp(key))
                return true;
            else
                return false;
        }

        public Keys[] CurrentPressedKeys()
        {
            return currentKeyboardState.GetPressedKeys();
        }

        public Keys[] PreviousPressedKeys()
        {
            return previousKeyboardState.GetPressedKeys();
        }

        #endregion

    }
}
